package kr.hkit.androidcomplete01.ch07;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;

public class OffScreen extends Activity{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyView mv = new MyView(this);
		setContentView(mv);
	}

	class MyView extends View{
		Paint pnt = new Paint();
		Bitmap BackBit;
		
		public MyView(Context context) {
			super(context);
		}

		public void onDraw(Canvas canvas){
			canvas.drawColor(Color.LTGRAY);
			BackBit = Bitmap.createBitmap(500, 300, Bitmap.Config.ARGB_8888);
			Canvas offScreen = new Canvas(BackBit);
			offScreen.drawColor(Color.GREEN);
			pnt.setColor(Color.RED);
			for(int x=0;x<500;x+=10){
				offScreen.drawLine(x, 0, 500-x, 300, pnt);
			}
			canvas.drawBitmap(BackBit, 10, 10, null);
		}
	}
}
